package com.ztf.shopping.web.servlet;

import com.ztf.shopping.service.UserService;
import com.ztf.shopping.service.imp.UserServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 增加订单
 */
@WebServlet("/addOrder")
public class AddOrder extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Object loginUser = request.getSession().getAttribute("loginUser");
        if (loginUser==null){
            //用户未登录
            request.getRequestDispatcher("login.html").forward(request,response);
            return;
        }
        String id = request.getParameter("id");
        UserService userService = new UserServiceImp();
        userService.addOrder(loginUser,id);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
